<?php
/**
 * Klasa obsługi tablicy default_user
 *
 */
class DefaultUserDAL extends DefaultDAL{


	protected static $objClassName =  'DefaultUser';
	protected static $objClassTable = 'default_user';
	protected static $objClassTablePK = 'id_default_user';
	private static $optClass;

	


	public static function Save(DalData $dalObj) {
		if($dalObj->getObj()->GetId()=='-1') {
			return self::DefaultInsert($dalObj);
		} else {
			return self::DefaultUpdate($dalObj);
		}
	}

	public static function Insert(DalData $dalObj) {
		return self::DefaultInsert($dalObj);
	}

	public static function Update(DalData $dalObj) {
		return self::DefaultUpdate($dalObj);
	}

	public static function GetById(DalData $dalObj) {
		return self::DefaultGetById($dalObj);
	}

	public static function Delete(DalData $dalObj) {
		return self::DefaultDelete($dalObj);
	}

	public static function GetResult(DalData $dalObj) {
		return self::DefaultGetResult($dalObj);
	}

	public static function GetResultByLink($table, $id ,$destination = false, $data = array(), $queryFields = array(), $limit = 0, $sortBy = null,$count = null)
	{
		$dalData = new DalData();
		$dalData->setObjClassName(self::GetObjClassName());
		$dalData->setObjClassTable(self::GetObjClassTable());
		$dalData->setObjClassTablePK(self::GetObjClassTablePK());
		$dalData->setOptClass(self::GetOptClass());
		$dalData->setCondition($data);
		$dalData->setQueryFields($queryFields);
		$dalData->setLimit($limit);
		$dalData->setSortBy($sortBy);
		$dalData->setCount($count);
		$dalData->setDataArray("mf_link_id", $id);
		$dalData->setDataArray("mf_link_table", $table);
		$dalData->setDataArray("mf_link_destination", $destination);
		return self::DefaultGetResultByLink($dalData);
	}


	public static function GetObjClassName() {
		if(self::$objClassName != '') {
			$class = self::$objClassName;
		} else {
			$class = ereg_replace('DAL', '', __CLASS__);
		}

		return $class;
	}

	public static function GetOptClass() {
		if(self::$optClass!=null) {
			return self::$optClass;
		} else {
			return self::GetObjClassName();
		}
	}

	public static function GetObjClassTablePK() {
		if(self::$objClassTablePK != '') {
			$return = self::$objClassTablePK;
		} else {
			$class = self::GetObjClassName();
			$classObj = new $class();
			$return = $classObj->GetClassTablePK();
		}
		return $return;
	}

	public static function GetObjClassTable() {
		if(self::$objClassTable!='') {
			$return = self::$objClassTable;
		} else {
			$class = self::GetObjClassName();
			$classObj = new $class();
			$return = $classObj->GetTableName();
		}

		return $return;
	}

	/**
	 *
	 * @return DalData $dalData
	 */
	public static function GetDalDataObj($params = array()) {

		$dalData = new DalData($params);
		$dalData->setObjClassName(self::GetObjClassName());
		$dalData->setObjClassTable(self::GetObjClassTable());
		$dalData->setObjClassTablePK(self::GetObjClassTablePK());
		$dalData->setOptClass(self::GetOptClass());

		return $dalData;
	}

}
?>